#!/usr/bin/perl
# to select the overlap portion of 1_flow_table.csv, in particular, when sending rate of flow1 > flow

#folders
$root_folder="/root/switch_project";
$result_folder="$root_folder/experiment/exp23"; #root dir to store experimental resutls
$dst_folder="/root/temp/exp23";
$source_file1="1_flow_table.csv";
$source_file2="2_flow_table.csv";
$source_file3="2_ref_flow_info.csv";
$source_file4="1_ref_flow_info.csv";
$source_file5="flow_table.csv";
$source_file6="flow_table_sorted.csv";

$runs=1; # number of repeated experiment (same setting)

@speed;

#specify sending rate
$start_sending_rate=100;#Mb/s
$end_sending_rate=1000;
$sending_rate_gap=100;

#calculate speed and gap (gap is not used for now)
for($b=$start_sending_rate, $a=0; $b<=$end_sending_rate; $b+=$sending_rate_gap, $a++)
{
	$speed[$a]=$b;
}

mkdir "$dst_folder";

for($j=0; $j<=$#speed; $j++)
#for($j=8; $j<=8; $j++)
{
	for($k=0; $k<=$#speed; $k++)
	{
		for($i=1; $i<=$runs; $i++)
		{	
	
			mkdir "$dst_folder/$speed[$j]M";
			mkdir "$dst_folder/$speed[$j]M/$speed[$k]M";
			mkdir "$dst_folder/$speed[$j]M/$speed[$k]M/$i";

			#mkdir "$dst_folder/900M";
			#mkdir "$dst_folder/900M/$speed[$k]M";
			#mkdir "$dst_folder/900M/$speed[$k]M/$i";

			print "src folder = $result_folder/$speed[$j]M/$speed[$k]M/$i\n";
			print "dst folder = $dst_folder/$speed[$j]M/$speed[$k]M/$i\n";

			#system("cp $result_folder/900M/$speed[$k]M/$i/$source_file1 $dst_folder/900M/$speed[$k]M/$i/$source_file1");
			#system("cp $result_folder/900M/$speed[$k]M/$i/$source_file2 $dst_folder/900M/$speed[$k]M/$i/$source_file2");
			#system("cp $result_folder/900M/$speed[$k]M/$i/$source_file6 $dst_folder/900M/$speed[$k]M/$i/$source_file6");

			system("cp $result_folder/$speed[$j]M/$speed[$k]M/$i/$source_file1 $dst_folder/$speed[$j]M/$speed[$k]M/$i/$source_file1");
			system("cp $result_folder/$speed[$j]M/$speed[$k]M/$i/$source_file2 $dst_folder/$speed[$j]M/$speed[$k]M/$i/$source_file2");
			#system("cp $result_folder/$speed[$j]M/$speed[$k]M/$i/$source_file3 $dst_folder/$speed[$j]M/$speed[$k]M/$i/$source_file3");
			#system("cp $result_folder/$speed[$j]M/$speed[$k]M/$i/$source_file4 $dst_folder/$speed[$j]M/$speed[$k]M/$i/$source_file4");
			#system("cp $result_folder/$speed[$j]M/$speed[$k]M/$i/$source_file5 $dst_folder/$speed[$j]M/$speed[$k]M/$i/$source_file5");
			system("cp $result_folder/$speed[$j]M/$speed[$k]M/$i/$source_file6 $dst_folder/$speed[$j]M/$speed[$k]M/$i/$source_file6");
		}
	}
}

chdir "$root_folder/script";
